<?php
/**
 * 菜单相关接口请求参数验证器
 * Created by PhpStorm.
 * User: LRChang
 * Date: 2018/6/14
 * Time: 09:51
 * Mail: hjklrchang@qq.com
 */

namespace app\adminapi\validate;

use app\base\validate\BaseValidate;

class MenuValidate extends BaseValidate
{
    protected $rule = [

        'id' => 'require|isPositiveInt',
        'name' => 'require|max:32',
        'pid' => 'require|integer',
        'url' => 'require|max:64',
        'icon' => 'max:16',
        'sort' => 'isPositiveInt',
        'state' => 'require|in:1,9',
        'where_json' => 'isWhereJson',
        'ids' => 'require|checkIDs',
    ];

    // 默认值
    protected $default = [
        'is_tree' => 1,
    ];

    protected $message = [

    ];

    protected $scene = [
        'tree' => [
            'is_tree'
        ],
        'add' => [
            'name',
            'pid',
            'url',
            'icon',
            'sort',
            'state',
            'module_type',
        ],
        'edit' => [
            'id',
            'name',
            'pid',
            'url',
            'icon',
            'sort',
            'state',
            'module_type',
        ],
        'delete' => [ 'ids' ],
    ];
}